package it.test.service;

import it.test.commons.BasePojo;
import it.test.commons.DTO;
import it.test.dao.BaseDAO;

import java.io.Serializable;
import java.util.List;

import org.springframework.transaction.annotation.Transactional;
@Transactional
public class AbstractBaseService<T extends BasePojo, ID extends Serializable> implements BaseService<T, ID> {
	
	protected BaseDAO<T, ID> dao;
	
	
	/* (non-Javadoc)
	 * @see it.marco.test.service.BaseService#setDao(it.marco.test.dao.BaseDAO)
	 */
	@SuppressWarnings("unchecked")
	public void setDao(BaseDAO<T, ID> dao) {
		this.dao = (BaseDAO<T, ID>)dao;
	}


	
	public List<T> findAll() {
		return dao.findAll();
	}

	@Transactional
	public void delete(DTO<T> dto) {
		dao.delete(dto);
		
	}


	@SuppressWarnings("unchecked")
	public DTO<T> find(Serializable id) {
		return dao.find((ID)id);
	}

	@Transactional
	public void save(DTO<T> dto) {
		dao.save(dto);
	}

	@Transactional
	public void saveOrUpdate(DTO<T> dto) {
		dao.saveOrUpdate(dto);
		
	}


	
	
	
	
	
		
	

	
	
}

